Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-promise

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-promise

Enforce best practices for JavaScript promises

  • 3.8.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is eslint-plugin-promise?

The eslint-plugin-promise package is an ESLint plugin that enforces best practices and common idioms for dealing with promises in JavaScript. It provides a set of rules that catch common mistakes and enforce conventions when working with promises.

What are eslint-plugin-promise's main functionalities?

Avoiding creation of new promises outside of utility libraries

This rule ensures that the executor function of a new Promise has the parameters named 'resolve' and 'reject'.

/* eslint promise/param-names: 'error' */
new Promise((resolve, reject) => { /* executor function */ });

Ensuring that each time a then() is applied to a promise, a catch() is applied as well

This rule enforces the use of catch() on unhandled promises.

/* eslint promise/catch-or-return: 'error' */
promise.then(function(data) {
  // handle data
}).catch(function(error) {
  // handle error
});

Enforcing the return of a promise in certain contexts

This rule ensures that promise chains always return a value, preventing silent failures and unhandled rejections.

/* eslint promise/always-return: 'error' */
function foo() {
  return doSomething().then(function() {
    // do something else
    return 'result';
  });
}

Other packages similar to eslint-plugin-promise

Keywords

FAQs

Package last updated on 24 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc